<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Categories model
 *
 * @package		PyroCMS
 * @subpackage	Categories Module
 * @category	Modules
 * @author		Phil Sturgeon - PyroCMS Dev Team
 */
class Escort_messages_m extends MY_Model
{
	public function get_message($id, $solver_permission_slug){
		$this->db->select('escort_messages.*')
			->join('escort_message_threads', 'escort_message_threads.id = escort_messages.thread_id', 'left');
		$this->db->where('escort_messages.id', $id);
		$this->db->where('escort_message_threads.solver_permission_slug', $solver_permission_slug);
		return $this->db->get('escort_messages')
					->row();
	}
	public function check_read($read, $thread_id){
		$this->db->select('escort_messages.*')->where('read', $read)->where('thread_id', $thread_id);
		return $this->db->count_all_results('escort_messages');
	}
}